import Vuex from 'vuex'
import Vue from 'vue'
import Data from '@/server/server.js'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    orderListData: Data.orderList(), // 我的订单页面
    goodListData: Data.goodList(), // 默认是为你推荐
    fillOrder: {},
    addressData: Data.address, // 收货地址
    userPlaces: {},
    editorAddressObj: Data.address(),
    products: [],
    orderBtn: [],
    specificationData: Data.specification, // 产品规格
    refundData: Data.refund, // 退款
    couponCodeData: Data.couponCode() // 优惠劵
  },
  getters: {
  },
  mutations: {
    changeGoodListData (state, val) {
      state.goodListData = Data.goodList(val)
    },
    changeEntrys (state, obj) {
      state.products[obj.indexs] = obj.value
    },
    changeOrderListData (state, status) {
      state.orderListData = Data.orderList(status)
    },
    changeCouponCodeData (state, num) { // 优惠劵
      state.couponCodeData = Data.couponCode(num)
    },
    editorAddress (state, val) { // 编辑收货地址 修改数据
      state.editorAddressObj = Data.address(val)
    },
    clearEditorAddressObj (state) { // 新增收货地址的时候 清除数据
      state.editorAddressObj = {}
    }
  },
  actions: {
    increment (context) {
      context.commit('increment')
    }
  }
})
